@extends('content.layouts.default')
@section('content')
    <div class="card">
        <div class="card-body">
            <ul class="nav nav-tabs nav-overflow header-tabs">
                <li class="nav-item">
                    <a href="{{route('content.category.index')}}" class="nav-link pb-3 active">
                        栏目列表
                    </a>
                </li>
                <li class="nav-item">
                    <a href="{{route('content.category.create')}}" class="nav-link pb-3">
                        发表栏目
                    </a>
                </li>
            </ul>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>栏目名称</th>
                    <th>封面栏目</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($categorys as $v)
                    <tr>
                        <td scope="row">{{$v['id']}}</td>
                        <td>{{$v['_title']}}</td>
                        <td>
                            @if($v['is_home'])
                                <span class="fe fe-check-circle text-info"></span>
                                @else
                                <span class="fe fe-x-circle mr-4 text-secondary"></span>
                                @endif
                        </td>
                        <td>{{$v['created_at']}}</td>
                        <td class="text-right">
                            <div class="btn-group btn-group-sm" role="group" aria-label="First group">
                                <a href="{{route('content.category.edit',$v['id'])}}"
                                   class="btn btn-light btn-sm">编辑</a>
                                <form action="{{route('content.category.destroy',$v['id'])}}" method="post">
                                    @csrf
                                    @method('DELETE')
                                    <button type="button" class="btn btn-sm btn-dark" onclick="del(this)">删除</button>
                                </form>
                                <div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>

    </div>
@endsection

@push('js')
    <script>
        function del(obj) {
            if(confirm('确定要删除吗?')){
                 this.submit();
            }else {
                return false;
            }
        }
    </script>
@endpush
